<template>
	<view>
		<!-- 自定义导航栏 -->
		<z-nav-bar transparentFixedFontColor="#FFF" type="transparentFixed" title="我的预约"></z-nav-bar>
		<view class="head flex align-item column">
			<view class="head-code">
				<uqrcode ref="uQRCode" :text="order_sn" size="121"/>
			</view>
			<view class="head-id">
				{{ activityData.order_sn || '' }}
			</view>
		</view>
		<view class="main">
			<view class="main-head">
				<view class="main-head-con flex align-item">
					<view class="main-head-con-logo">
						<image :src="hunlianLogoUrl" mode=""></image>
					</view>
					<view class="main-head-con-info">
						<view class="main-head-con-info-tit">
							{{ activityData.title || '' }}
						</view>
						<view class="main-head-con-info-subtit">
							{{ activityData.subtitle || '' }}
						</view>
					</view>
				</view>
				<view class="main-head-detail flex align-item j-between">
					<view class="main-head-detail-left">
						<view class="flex align-item">
							<view class="">
								已报名：
							</view>
							<view class="con-t">
								{{ activityData.sign_up_num || '' }}
							</view>
							<view class="">
								/{{ activityData.activity_num || '' }}人
							</view>
						</view>
						<view class="flex align-item info-time">
							<view class="">
								报名时间：
							</view>
							<view class="">
								{{ activityData.sign_up_start_time || '' }} -- {{ activityData.sign_up_end_time || '' }}
							</view>
						</view>
						<view class="flex align-item info-time">
							<view class="">
								活动开始时间：
							</view>
							<view class="">
								{{ activityData.start_time || '' }}
							</view>
						</view>
						<view class="flex align-item">
							<view class="">
								地址：
							</view>
							<view class="" style="width: 400rpx;">
								{{ activityData.address || '' }}
							</view>
						</view>
					</view>
					<view class="main-head-detail-right flex align-item column"  @click="goMap">
						<image class="daohang-logo" :src="imgUrl + 'static/web/icon/daohang.png'" mode=""></image>
						<view class="">
							地址导航
						</view>
					</view>
				</view>
			</view>
			<view class="main-con">
				<view class="con-title">
					预约信息
				</view>
				<view class="con-item flex align-item j-between">
					<view class="">
						姓名：
					</view>
					<view class="">
						{{ activityData.real_name || '' }}
					</view>
				</view>
				<view class="con-item flex align-item j-between">
					<view class="">
						电话：
					</view>
					<view class="">
						{{ activityData.phone || '' }}
					</view>
				</view>
				<view class="foot-btn flex align-item" v-if="activityData.is_cancel == '1'">
					<view class="btn-com btn-baoming" @click="cancelSignUp">
						取消报名
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex';
	export default {
		data() {
			return {
				imgUrl: this.$http.baseUrl, // 服务器域名
				activity_id: '', // 活动id
				uid: '', // 用户id
				activityData: [], // 存储活动详情信息
				order_sn: '', // 订单号
				hunlianLogoUrl: '',
			}
		},
		computed: {
			...mapState(['userInfo']),
		},
		methods: {
			getActivityData(){
				var that = this
				if(!that.uid){
					uni.showToast({
					    title: '请前往授权登录',
					    duration: 1000
					});
					setTimeout(function() {
						uni.switchTab({
							url: '/pages/my/my'
						});
					}, 1000);
				}else {
					that.$http.get('api/ZhMyActivity/view',{
						'activity_id': that.activity_id
					}).then(res => {
							if(res){
								that.activityData = res
								that.order_sn = res.order_sn
							}
						});
				}
			},
			// 去地图导航
			goMap(){
				var that = this
				uni.openLocation({
					latitude: that.activityData.coordinate.latitude,
					longitude: that.activityData.coordinate.longitude,
					success: function () {
						console.log('success','成功');
					},
					fail: function(){
						console.log('err','失败')
					}
				});
			},
			// 取消报名
			cancelSignUp(){
				var that = this
				that.$http.post('api/ZhSignUp/cancelSignUp',{
					'activity_id': that.activity_id
				}).then(res => {
						uni.showToast({
							title: '取消报名成功',
							icon: 'none'
						})
						setTimeout(function() {
							uni.navigateBack({
								
							})
						}, 1000);
					});
			}
		},
		onLoad(e) {
			this.hunlianLogoUrl = this.$base.logoUrl
			var userInfo = this.$store.state.userInfo;
			this.uid = userInfo.uid
			this.activity_id = e.activity_id
			this.getActivityData()
		},
		
	}
</script>
<style>
page {
	background-color: #F9F9F9;
}
</style>
<style lang="scss" scoped>
.flex {
	display: flex;
}
.align-item {
	align-items: center;
}
.j-between {
	justify-content: space-between;
}
.column {
	flex-direction: column;
}
.head {
	justify-content: center;
	width: 100%;
	height: 682rpx;
	background-color: #7F5AFF;
	.head-code {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 295rpx;
		height: 295rpx;
		border-radius: 24rpx;
		margin-top: 64rpx;
		border: 26rpx solid #FFFFFF;
		background-color: #FFFFFF;
	}
	.head-id {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		margin-top: 24rpx;
	}
}
.main {
	padding: 0 30rpx;
	.main-head {
		background-color: #FFFFFF;
		padding: 40rpx 30rpx 40rpx;
		border-radius: 24rpx;
		margin-top: -70rpx;
		.main-head-con {
			.main-head-con-logo {
				width: 120rpx;
				height: 120rpx;
				border-radius: 20rpx;
				overflow: hidden;
				image {
					width: 100%;
					height: 100%;
				}
			}
			.main-head-con-info {
				margin-left: 24rpx;
				.main-head-con-info-tit {
					font-size: 40rpx;
					font-family: PingFangSC-Semibold, PingFang SC;
					font-weight: 600;
					color: #000013;
					margin-bottom: 20rpx;
				}
				.main-head-con-info-subtit {
					font-size: 28rpx;
					font-family: PingFangSC-Light, PingFang SC;
					font-weight: 300;
					color: #6A6A7E;
				}
			}
		}
		.main-head-detail {
			margin-top: 38rpx;
			.main-head-detail-left {
				width: 80%;
				font-size: 26rpx;
				font-family: PingFangSC-Light, PingFang SC;
				font-weight: 300;
				color: #000013;
				.info-time {
					margin: 20rpx 0;
				}
				.con-t {
					color: #7F5AFF;
				}
			}
			.main-head-detail-right {
				width: 20%;
				font-size: 26rpx;
				font-family: PingFangSC-Light, PingFang SC;
				font-weight: 300;
				color: #000013;
				.daohang-logo {
					width: 64rpx;
					height: 64rpx;
					margin-bottom: 10rpx;
				}
			}
		}
	}
	.main-con {
		padding: 40rpx 30rpx;
		background-color: #fff;
		margin-top: 30rpx;
		.con-title {
			font-size: 32rpx;
			font-family: PingFangSC-Semibold, PingFang SC;
			font-weight: 600;
			color: #000013;
			margin-bottom: 40rpx;
		}
		.con-item {
			font-size: 28rpx;
			font-family: PingFangSC-Light, PingFang SC;
			font-weight: 300;
			color: #6A6A7E;
			margin-bottom: 24rpx;
		}
		.con-item:nth-child(3){
			margin-bottom: 0;
		}
	}
	.foot-btn {
		justify-content: center;
		margin-top: 40rpx;
		.btn-com {
			width: 80%;
			height: 80rpx;
			border-radius: 16rpx;
			text-align: center;
			line-height: 80rpx;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
		}
		.btn-baoming {
			background: #7F5AFF;
		}
	}
}
</style>
